home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 34 / Amiga Format CD34 (1998-11-20)(Future Publishing)(GB)[!][Christmas issue].iso / -seriously_amiga- / programming / c / viewperf5.1 / viewperf / objs / trif.c < prev    next >
C/C++ Source or Header  |  1998-10-01  |  19KB  |  460 lines

  1. #ifdef WIN32
  2. #include <windows.h>
  3. #endif
  4. #include <GL/gl.h>
  5. #include "viewperf.h"
  6. #include "vpDefine.h"
  7.  
  8. void FUNCTION(struct ThreadBlock *tb) {
  9.         int polyi,verti;
  10.     int numverts;
  11.     int polycount = tb->np;
  12.         GLenum mode = tb->mode;
  13. #ifdef BATCH
  14.         int groupi;
  15.         int batchi;
  16.         int leftoveri;
  17.         int batchcount = tb->batchnum;
  18.         int groupcount = tb->batchgroups;
  19.         int leftovercount = tb->batchleftovers;
  20. #endif
  21. #ifdef EXTERNAL
  22.         GLenum capability = tb->capability;
  23.         void (*lExternfunc)(GLenum) = tb->externfunc;
  24. #endif
  25.     int *vertindex;
  26. #ifdef BY_TWO
  27.     int *startvertindex;
  28. #endif
  29.  
  30.     struct vector *pvert=tb->vert;
  31.     struct plygon *pply=tb->ply;
  32.  
  33. #ifndef FUNCTION_CALLS
  34. #ifdef WIN32
  35.         void (APIENTRY *glVertex3fvP)(const GLfloat *);
  36. #else
  37.         void (*glVertex3fvP)(const GLfloat *);
  38. #endif
  39. #endif
  40.  
  41.  
  42. #if defined(FACET_NORM) || defined(VERT_NORM)
  43.     struct vector *pvnorm=tb->vnorm;
  44. #ifndef FUNCTION_CALLS
  45. #ifdef WIN32
  46.         void (APIENTRY *glNormal3fvP)(const GLfloat *);
  47. #else
  48.         void (*glNormal3fvP)(const GLfloat *);
  49. #endif
  50. #endif  /* ifndef FUNCTION_CALLS */
  51. #endif
  52.  
  53.  
  54. #if defined(FACET_COLOR) || defined(VERT_COLOR)
  55.     struct colorvector *pvcolor=tb->vcolor;
  56. #ifndef FUNCTION_CALLS
  57. #ifdef WIN32
  58.         void (APIENTRY *glColorP)(const GLfloat *);
  59. #else
  60.         void (*glColorP)(const GLfloat *);
  61. #endif
  62. #endif  /* ifndef FUNCTION_CALLS */
  63. #endif
  64.  
  65.  
  66. #ifdef TEXTURE
  67.     struct vector *ptexture=tb->texture;
  68. #ifndef FUNCTION_CALLS
  69. #ifdef WIN32
  70.         void (APIENTRY *glTexCoord2fvP)(const GLfloat *);
  71. #else
  72.         void (*glTexCoord2fvP)(const GLfloat *);
  73. #endif
  74.         glTexCoord2fvP = glTexCoord2fv;
  75. #endif  /* ifndef FUNCTION_CALLS  */
  76. #endif
  77.  
  78.  
  79. #ifndef FUNCTION_CALLS
  80. #if defined(FACET_COLOR) || defined(VERT_COLOR)
  81.         glColorP = tb->ColorP;
  82. #endif
  83. #if defined(FACET_NORM) || defined(VERT_NORM)
  84.         glNormal3fvP = glNormal3fv;
  85. #endif
  86.         glVertex3fvP = glVertex3fv;
  87. #endif  
  88.  
  89.  
  90.  
  91. #ifdef BATCH
  92.         polyi = polycount;
  93.         for(groupi=groupcount-1;groupi>=0;groupi--) {
  94.                 glBegin(mode);
  95.                 for(batchi=batchcount-1;batchi>=0;batchi--) {
  96.                 polyi--;
  97. #else
  98.         for(polyi=polycount-1;polyi>=0;polyi--) {
  99. #endif
  100.         numverts = pply[polyi].numverts;
  101.         vertindex = pply[polyi].index;
  102. #ifdef BY_TWO
  103.         startvertindex = vertindex;
  104. #endif
  105. #ifdef EXTERNAL
  106.                 lExternfunc(capability);
  107. #endif
  108. #if    defined(FACET_COLOR) && !defined(FUNCTION_CALLS)
  109.                 (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  110. #elif  defined(FACET_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  111.                 glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  112. #elif  defined(FACET_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  113.                 glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  114. #endif
  115. #if    defined(FACET_NORM) && !defined(FUNCTION_CALLS)
  116.                 (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  117. #elif  defined(FACET_NORM) &&  defined(FUNCTION_CALLS)
  118.                 glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  119. #endif
  120. #ifndef BATCH
  121.                 glBegin(mode);
  122. #endif
  123. #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  124.                     (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  125. #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS)  && !defined(COLOR4)
  126.                     glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  127. #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS)  &&  defined(COLOR4)
  128.                     glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  129. #endif
  130. #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)
  131.                         (*glTexCoord2fvP)((const GLfloat *) (ptexture + *vertindex));
  132. #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  133.                         glTexCoord2fv((const GLfloat *) (ptexture + *vertindex));
  134. #endif
  135. #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS)
  136.                         (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  137. #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  138.                         glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  139. #endif
  140. #ifdef FUNCTION_CALLS
  141.                         glVertex3fv((const GLfloat *) (pvert + *vertindex));
  142. #else
  143.                         (*glVertex3fvP)((const GLfloat *) (pvert + *vertindex));
  144. #endif
  145.  
  146. #ifdef BY_TWO
  147.             vertindex++;
  148.   #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  149.                         (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  150.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS)  && !defined(COLOR4)
  151.                         glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  152.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS)  &&  defined(COLOR4)
  153.                         glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  154.   #endif   
  155.   #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)   
  156.                         (*glTexCoord2fvP)((const GLfloat *) (ptexture + *vertindex));
  157.   #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  158.                         glTexCoord2fv((const GLfloat *) (ptexture + *vertindex));
  159.   #endif   
  160.   #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS) 
  161.                         (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  162.   #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  163.                         glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  164.   #endif   
  165.   #ifdef FUNCTION_CALLS 
  166.                         glVertex3fv((const GLfloat *) (pvert + *vertindex));
  167.   #else 
  168.                         (*glVertex3fvP)((const GLfloat *) (pvert + *vertindex));
  169.   #endif   
  170. #else
  171.             vertindex++;
  172. #endif
  173.  
  174. #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  175.                         (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  176. #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS)  && !defined(COLOR4)
  177.                         glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  178. #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS)  &&  defined(COLOR4)
  179.                         glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  180. #endif   
  181. #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)   
  182.                         (*glTexCoord2fvP)((const GLfloat *) (ptexture + *vertindex));
  183. #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  184.                         glTexCoord2fv((const GLfloat *) (ptexture + *vertindex));
  185. #endif   
  186. #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS) 
  187.                         (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  188. #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  189.                         glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  190. #endif   
  191. #ifdef FUNCTION_CALLS 
  192.                         glVertex3fv((const GLfloat *) (pvert + *vertindex));
  193. #else 
  194.                         (*glVertex3fvP)((const GLfloat *) (pvert + *vertindex));
  195. #endif   
  196.  
  197. #ifdef BY_TWO
  198.             vertindex++;
  199.   #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  200.                         (*glColorP)((const GLfloat *) (pvcolor + *vertindex));
  201.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS)  && !defined(COLOR4)
  202.                         glColor3fv((const GLfloat *) (pvcolor + *vertindex));
  203.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS)  &&  defined(COLOR4)
  204.                         glColor4fv((const GLfloat *) (pvcolor + *vertindex));
  205.   #endif   
  206.   #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)   
  207.                         (*glTexCoord2fvP)((const GLfloat *) (ptexture + *vertindex));
  208.   #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  209.                         glTexCoord2fv((const GLfloat *) (ptexture + *vertindex));
  210.   #endif   
  211.   #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS) 
  212.                         (*glNormal3fvP)((const GLfloat *) (pvnorm + *vertindex));
  213.   #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  214.                         glNormal3fv((const GLfloat *) (pvnorm + *vertindex));
  215.   #endif   
  216.   #ifdef FUNCTION_CALLS 
  217.                         glVertex3fv((const GLfloat *) (pvert + *vertindex));
  218.   #else 
  219.                         (*glVertex3fvP)((const GLfloat *) (pvert + *vertindex));
  220.   #endif   
  221. #else
  222.             vertindex++;
  223. #endif
  224.  
  225. #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)